
#include "Logger/LogLogger.h"

namespace logger {

Logger::Logger(Level level) : m_level{level} {
}

void Logger::log(Level level, const LogEntry& entry) {
    if (shouldLog(level)) {
        emit(level, std::chrono::system_clock::now(), entry.c_str());
    }
}

void Logger::setLevel(Level level) {
    if (m_level != level) {
        m_level = level;
    }
#ifndef MV_DEBUG_LOG_ENABLED
    if (m_level <= Level::DEBUG0) {
        // Log without MV_* macros to avoid recursive invocation of constructor.
        log(Level::WARN,
            LogEntry("Logger", "debugLogLevelSpecifiedWhenDebugLogsCompiledOut")
                .d("level", m_level)
                .m("\n"
                   "\nWARNING: By default DEBUG logs are compiled out of RELEASE builds."
                   "\nTo enable debug logs, rebuild in DEBUG mode by using the cmake parameter "
                   "-DMV_DEBUG_LOG_ENABLED"
                   "\n"));
    }
#endif
}

void Logger::emit(
    Level level,
    std::chrono::system_clock::time_point time,
    const char* text) {
    // no-op.
}

}  // namespace logger
